package com.android.phoenix.activity.discovery;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.android.phoenix.Constant;
import com.android.phoenix.R;
import com.android.phoenix.activity.BaseActivity;

public class RankListActivity extends BaseActivity{
	private ListView listRank;
	private BaseAdapter mAdapter;
	private ImageView imgBack;
	
	private List<String> mList = new ArrayList<String>();
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acti_rank_list);
		
		listRank = (ListView) findViewById(R.id.listRank);
		mAdapter = new RankAdapter();
		listRank.setAdapter(mAdapter);
		listRank.setOnItemClickListener(RankListener);
		
		imgBack = (ImageView)findViewById(R.id.imgBack);
		imgBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		mList.add("年度总排名");
		mList.add("上月度排名");
		mList.add("当地年度排名");
		mList.add("当地上月度排名");
		mList.add("总里程排名");
		mList.add("最高速排名");
	}
	
	private OnItemClickListener RankListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			Intent intent = new Intent();
			intent.putExtra(Constant.RANK_NAME, mList.get(position));
			intent.setClass(RankListActivity.this, RankDetailActivity.class);
			startActivity(intent);
		}
	};
	
	private class RankAdapter extends BaseAdapter{

		@Override
		public int getCount() {
			return mList.size();
		}

		@Override
		public Object getItem(int position) {
			return mList.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			convertView = LayoutInflater.from(RankListActivity.this).inflate(R.layout.acti_rank_list_item, null);
			TextView tvListName = (TextView) convertView.findViewById(R.id.tvListName);
			tvListName.setText(mList.get(position));
			TextView tvRank = (TextView) convertView.findViewById(R.id.tvRank);
			tvRank.setText("100" + "名");
			return convertView;
		}
	}

}
